package com.j1ay.forum.controller;

import com.j1ay.forum.common.aop.LogAnnotation;
import com.j1ay.forum.common.cache.Cache;
import com.j1ay.forum.model.dto.params.CheckStatusParams;
import com.j1ay.forum.model.dto.params.PageParams;
import com.j1ay.forum.model.pojo.po.Check;
import com.j1ay.forum.model.pojo.vo.Result;
import com.j1ay.forum.service.CheckService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author J1ay
 * @Date 2021/12/21 18:07
 * @Description
 */
@RestController
@RequestMapping("api/check")

@Api(value="Check Controller",tags={"审核问题类接口"})
public class CheckController {

    @Autowired
    private CheckService checkService;

    @ApiOperation(value = "获取所有问题，包括未审核已审核")
    @PostMapping("all")
    // 记录日志
    @LogAnnotation(module = "审核", operation = "获取所有问题列表")
    public Result listAllQuestion(@RequestBody PageParams pageParams) {
        return checkService.listAllQuestion(pageParams);
    }

    @ApiOperation(value = "根据审核状态问题列表")
    @PostMapping("status")
    // 记录日志
    @LogAnnotation(module = "审核状态", operation = "根据审核状态问题列表")
    public Result listQuestionByStatus(@RequestBody CheckStatusParams checkStatusParams) {
        return checkService.listQuestionByStatus(checkStatusParams);
    }

    @ApiOperation(value = "查看所有审核列表")
    @PostMapping("checkList")
    @Cache(expire = 5 * 60 * 1000, name = "checkList")
    public Result getCheckList(@RequestBody PageParams pageParams) {
        return checkService.getCheckList(pageParams);
    }

    @ApiOperation(value = "根据id查看审核列表")
    @PostMapping("checkListById")
    @Cache(expire = 5 * 60 * 1000, name = "checkListById")
    public Result getCheckListByUserId (@RequestBody PageParams pageParams) {
        return checkService.getCheckListByUserId(pageParams);
    }

    @ApiOperation(value = "审核")
    @PostMapping("check")
    public Result toCheck(@RequestBody Check check) {
        return checkService.toCheck(check);
    }
}
